//
//  GroupTableViewCell.m
//  QRMaster
//
//  Created by myApple on 15/10/12.
//  Copyright (c) 2015年 myApple. All rights reserved.
//

#import "GroupTableViewCell.h"
#import "chooseColor.h"

@interface GroupTableViewCell()
{
    UILabel * groupNameLabel;
    UILabel * groupManagerNameLabel;
    UILabel * groupManagerAccountLabel;
    UIImageView * groupImageView;
    UILabel * titleHeaderLabel;
}

@end

@implementation GroupTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self prepareView];
    }
    return self;
}

-(void)prepareView
{
    self.backgroundColor = [UIColor whiteColor];
    float ScreenWidth = [UIScreen mainScreen].bounds.size.width;
    float x = 60;
    float y = 20;
    float width = ScreenWidth - x - 10;
    float heigth = 20;
    
    groupNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, y, width, heigth)];
    groupNameLabel.font = [UIFont systemFontOfSize:16.0];
    [self.contentView addSubview:groupNameLabel];
    
//    y += heigth + 5;
//    heigth = 20;
//    width = 120;
//    groupManagerAccountLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, y, width, heigth)];
//    groupManagerAccountLabel.font = [UIFont systemFontOfSize:14.0];
//    [self.contentView addSubview:groupManagerAccountLabel];
//    
//    
//    x += width;
//    groupManagerNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, y, width, heigth)];
//    groupManagerNameLabel.font = [UIFont systemFontOfSize:14.0];
//    groupManagerNameLabel.textColor = FONTCOLORTHREE;
//    [self.contentView addSubview:groupManagerNameLabel];
    
    
    x = ScreenWidth - 60;
    y = 10;
    width = 40;
    heigth = 40;
    groupImageView = [[UIImageView alloc]initWithFrame:CGRectMake(x, y, width, heigth)];
    groupImageView.layer.cornerRadius = 20;
    groupImageView.layer.masksToBounds = YES;
    groupImageView.image = [UIImage imageNamed:@"groupHead"];
    [self.contentView addSubview:groupImageView];
    
    x = 0;
    y = 15;
    width = 40;
    heigth = 30;
    titleHeaderLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, y, width, heigth)];
    titleHeaderLabel.font = [UIFont systemFontOfSize:25.0];
    titleHeaderLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:titleHeaderLabel];
    
}


-(void)setTitleHead:(NSString *)titleHead
{
    _titleHead = titleHead;
    titleHeaderLabel.text = [_titleHead isEqualToString:@"}"]?@"#":_titleHead;
    
    //随机颜色
    [chooseColor getColorByRandom:titleHeaderLabel];
}


-(void)setGroupId:(NSString *)groupId
{
    _groupId = groupId;
}

-(void)setGroupManagerAccount:(NSString *)groupManagerAccount
{
    _groupManagerAccount = groupManagerAccount;
    groupManagerAccountLabel.text = groupManagerAccount;
}

-(void)setGroupManagerCertificate:(NSString *)groupManagerCertificate
{
    _groupManagerCertificate = groupManagerCertificate;
}

-(void)setGroupName:(NSString *)groupName
{
    _groupName = groupName;
    groupNameLabel.text = groupName;
}

-(void)setGroupManagerName:(NSString *)groupManagerName
{
    _groupManagerName = groupManagerName;
    groupManagerNameLabel.text = groupManagerName;
}

-(void)setGroupImage:(NSString *)groupImage
{
    _groupImage = groupImage;
    groupImageView.image = [UIImage imageNamed:groupImage];
}

@end
